home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 22 / PC Actual CD 22.iso / SHARE / prog / POVRAY / TREES.ZIP / selftree.inc < prev    next >
Encoding:
Text File  |  1997-03-19  |  14.1 KB  |  363 lines

  1. // c1997 by Stephan Kuhagen
  2. // stk@informatik.uni-bremen.de
  3. // mail me, send postcards, show me your pictures
  4.  
  5. #ifndef ( OBJECTNAME)
  6.    #declare OBJECTNAME       = "TREE"      // Name des Objects
  7. #end
  8.  
  9. #ifndef ( USESTDTRUNK)
  10.    #declare USESTDTRUNK      = "YES"       // Soll der Standardstamm benutzt werden ?
  11. #end
  12.  
  13. #ifndef ( TRUNKLEN)
  14.    #declare TRUNKLEN         = "5"         // LΣnge des Stammes (FLOAT, >0)
  15. #end
  16.  
  17. #ifndef ( TRUNKBASER)
  18.    #declare TRUNKBASER       = "1"         // Anfangsradius des Stammes (FLOAT, >0)
  19. #end
  20.  
  21. #ifndef ( TRUNKCAPR)
  22.    #declare TRUNKCAPR        = "0.5"       // Endradius des Stammes (FLOAT, >0)
  23. #end
  24.  
  25. #ifndef ( DEPTH)
  26.    #declare DEPTH            = 4           // Rekursionstiefe (INT, >0)
  27. #end
  28.  
  29. #ifndef ( BLEN)
  30.    #declare BLEN             = "5"         // AnfangslΣnge (MindestlΣnge) der ─ste (FLOAT, >0)
  31. #end
  32.  
  33. #ifndef ( LDIFF)
  34.    #declare LDIFF            = "0"         // Differenzwert AstlΣnge (wird zu BLEN addiert) (FLOAT, LDIFF> -BLEN)
  35. #end
  36.  
  37. #ifndef ( RADIUS)
  38.    #declare RADIUS           = "0.5"       // Anfangsradius fⁿr ─ste (FLOAT, >0)
  39. #end
  40.  
  41. #ifndef ( RADSCALE)
  42.    #declare RADSCALE         = "0.5"       // Skalierungswert fⁿr Astradius (FLOAT, >0) 
  43. #end
  44.  
  45. #ifndef ( RDIFF)
  46.    #declare RDIFF            = "0"         // Differenzwert fⁿr Astradius, wird von RADIUS subtrahiert (FLOAT, |RDIFF|<RADIUS)
  47. #end
  48.  
  49. #ifndef ( RECSCALE)
  50.    #declare RECSCALE         = "0.5"       // Skalierungswert fⁿr Rekursion (FLOAT, >0)
  51. #end
  52.  
  53. #ifndef ( SLOPEANGLE)
  54.    #declare SLOPEANGLE       = "45"        // Neigungswinkel der ─ste (FLOAT)
  55. #end
  56.  
  57. #ifndef ( SANGLEDIFF)
  58.    #declare SANGLEDIFF       = "0"         // Differenzwert fⁿr Neigungswinkel (wird zu SLOPEANGLE addiert) (FLOAT)
  59. #end
  60.  
  61. #ifndef ( ANGLESCALE)
  62.    #declare ANGLESCALE       = "1"         // Skalierungswinkel fⁿr Neigungswinkel (FLOAT)
  63. #end
  64.  
  65. #ifndef ( NRBRANCHES)
  66.    #declare NRBRANCHES       = "4"         // Anzahl ─ste (INT, >0) *** Funktion: PoV parsierbar, f(x)
  67. #end
  68.  
  69. #ifndef ( NRBDIFF)
  70.    #declare NRBDIFF          = "0"         // Differenzwert fⁿr Anzahl ─ste (wird zu NRBRANCHES addiert) (FLOAT)
  71. #end
  72.  
  73. #ifndef ( NRBSCALEADD)
  74.    #declare NRBSCALEADD      = "0"         // Skalierungswert fⁿr Anzahl ─ste (wird zu NRBRANCHES addiert)(FLOAT)
  75. #end
  76.  
  77. #ifndef ( NRBSCALEMUL)
  78.    #declare NRBSCALEMUL      = "1"         // Skalierungswert fⁿr Anzahl ─ste (wird mit NRBRANCHES multipliziert)(FLOAT)
  79. #end
  80.  
  81. #ifndef ( BRANCHTOP)
  82.    #declare BRANCHTOP        = "1"         // Wahrscheinlichkeitswert fⁿr Astansatzstelle (FLOAT, 0<=x<=1)
  83. #end
  84.  
  85. #ifndef ( LEAFINC)
  86.    #declare LEAFINC          = "NO"        // BlΣtterinclude (STRING, YES|NO)
  87. #end
  88.  
  89. #ifndef ( NRLEAFINCS)
  90.    #declare NRLEAFINCS       = 0           // Anzahl Blattincludes (INT, >=0)
  91. #end
  92.  
  93. #ifndef ( NRLEAFS)
  94.    #declare NRLEAFS          = "0"         // Anzahl BlΣtter pro Ast (INT, >=0)
  95. #end
  96.  
  97. #ifndef ( NRLDIFF)
  98.    #declare NRLDIFF          = "0"         // Differenzwert Anzahl BlΣtter pro Ast (wird zu NRLEAFS addiert)(INT, NRLDIFF> -NRLEAFS)
  99. #end
  100.  
  101. #ifndef ( ROTRANGE)
  102.    #declare ROTRANGE         = "360"       // Rotationsrange (FLOAT, 0<=x<=360)
  103. #end
  104.  
  105. #ifndef ( RANDINIT_ROT)
  106.    #declare RANDINIT_ROT     = "0.1234"    // Initialisierungswert fⁿr Rotations-Random (FLOAT)
  107. #end
  108.  
  109. #ifndef ( RANDINIT_LDIFF)
  110.    #declare RANDINIT_LDIFF   = "0.1234"    // Initialisierungswert fⁿr LDIFF-Random (FLOAT)
  111. #end
  112.  
  113. #ifndef ( RANDINIT_RDIFF)
  114.    #declare RANDINIT_RDIFF   = "0.1234"    // Initialisierungswert fⁿr RDIFF-Random (FLOAT)
  115. #end
  116.  
  117. #ifndef ( RANDINIT_SDIFF)
  118.    #declare RANDINIT_SDIFF   = "0.1234"    // Initialisierungswert fⁿr SANGLEDIFF-Random (FLOAT)
  119. #end
  120.  
  121. #ifndef ( RANDINIT_NRBDIFF)
  122.    #declare RANDINIT_NRBDIFF = "0.1234"    // Initialisierungswert fⁿr NRBDIFF-Random (FLOAT)
  123. #end
  124.  
  125. #ifndef ( RANDINIT_NRLDIFF)
  126.    #declare RANDINIT_NRLDIFF = "0.1234"    // Initialisierungswert fⁿr NRLDIFF-Random (FLOAT)
  127. #end
  128.  
  129. #ifndef ( RANDINIT_LEAFSELECT)
  130.    #declare RANDINIT_LEAFSELECT = "0.1234" // Initialisierungswert fⁿr LEAFSELECT-Random (FLOAT)
  131. #end
  132.  
  133. #ifndef ( RANDINIT_LEAFTRANS)
  134.    #declare RANDINIT_LEAFTRANS = "0.1234"  // Initialisierungswert fⁿr LEAFTRANS-Random (FLOAT)
  135. #end
  136.  
  137. #ifndef ( RANDINIT_LEAFROT)
  138.    #declare RANDINIT_LEAFROT = "0.1234"    // Initialisierungswert fⁿr LEAFROT-Random (FLOAT)
  139. #end
  140.  
  141. #ifndef ( RANDINIT_BT)
  142.    #declare RANDINIT_BT      = "0.1234"    // Initialisierungswert fⁿr Branchtop-Random (FLOAT)
  143. #end
  144.  
  145.  
  146.  
  147. // Default-Texture, muss vorhanden sein
  148. #default { pigment { color rgb <0.35, 0.16, 0.14> } }
  149.  
  150.  
  151.  
  152. /*********************************************************************
  153.  
  154.          DO NOT CHANGE ANYTHING HERE
  155.  
  156. *********************************************************************/
  157.  
  158. /*
  159.  
  160. // ▄berprⁿfung der Variablen NEU SCHREIBEN!!!!!!!!!!
  161.  
  162. */
  163.  
  164.  
  165.  
  166.  
  167. /*********************************************************************
  168.  
  169.   Ab hier wird das eigentliche Include-File erzeugt:
  170.  
  171. *********************************************************************/
  172.  
  173. #debug        "/*********************************************************************\n"
  174. #debug        "\n"
  175. #debug concat("   Objectname: ",OBJECTNAME,"\n")
  176. #debug        "\n"
  177. #debug        "*********************************************************************/\n\n"
  178.  
  179. // Initialisierung der Random-Streams
  180. #debug concat("#declare RANDROT_",OBJECTNAME,"        = seed(",RANDINIT_ROT,") // random for rotation\n")
  181. #debug concat("#declare RANDLDIFF_",OBJECTNAME,"      = seed(",RANDINIT_LDIFF,") // random for LDIFF\n")
  182. #debug concat("#declare RANDRDIFF_",OBJECTNAME,"      = seed(",RANDINIT_RDIFF,") // random for RDIFF\n")
  183. #debug concat("#declare RANDSDIFF_",OBJECTNAME,"      = seed(",RANDINIT_SDIFF,") // random for SANGLEDIFF\n")
  184. #debug concat("#declare RANDNRBDIFF_",OBJECTNAME,"    = seed(",RANDINIT_NRBDIFF,") // random for NRBDIFF\n")
  185. #debug concat("#declare RANDNRLDIFF_",OBJECTNAME,"    = seed(",RANDINIT_NRLDIFF,") // random for NRLDIFF\n")
  186. #debug concat("#declare RANDLEAFROT_",OBJECTNAME,"    = seed(",RANDINIT_LEAFROT,") // random for LEAFROT\n")
  187. #debug concat("#declare RANDLEAFTRANS_",OBJECTNAME,"  = seed(",RANDINIT_LEAFTRANS,") // random for LEAFTRANS\n")
  188. #debug concat("#declare RANDLEAFSELECT_",OBJECTNAME," = seed(",RANDINIT_LEAFSELECT,") // random for LEAFSELECT\n")
  189. #debug concat("#declare RANDBT_",OBJECTNAME,"         = seed(",RANDINIT_BT,") // random for BRANCHTOP\n\n")
  190.  
  191.  
  192.  
  193. // Vars for Statistics
  194. #debug "#declare NROFCONES = 0\n"
  195. #debug "#declare NROFSPHERES = 0\n"
  196. #debug "#declare NROFLEAFS = 0\n\n"
  197.  
  198.  
  199.  
  200. // Vars for backtracing rotations
  201. #debug "#declare BACKTRACER_X = 0\n"
  202. #debug "#declare BACKTRACER_Y = 0\n"
  203. #debug "#declare BACKTRACER_Z = 0\n\n"
  204. // Vars for backtracing translations
  205. #debug "#declare BACKTRACET_X = 0\n"
  206. #debug "#declare BACKTRACET_Y = 0\n"
  207. #debug "#declare BACKTRACET_Z = 0\n\n"
  208.  
  209.  
  210.  
  211. // ╓ffnen der Union OBJECTNAME
  212. #declare INCDEPTH = 0
  213. #debug concat("#declare X = ",str(INCDEPTH,0,0),"\n")
  214. #debug        "\n"
  215. #debug concat("#declare ",OBJECTNAME," =\n")
  216. #debug        "union\n"
  217. #debug        "{\n"
  218. #debug        "   // Baumstamm erzeugen\n"
  219.  
  220. #if ( strcmp(USESTDTRUNK,"NO") != 0 )
  221.    #debug        "   union\n"
  222.    #debug        "   {\n"
  223.    #debug concat("       cone { <0, 0, 0>, ",TRUNKBASER,", <0, ",TRUNKLEN,", 0>, ",TRUNKCAPR," }\n")
  224.    #debug        "       #declare NROFCONES = NROFCONES + 1\n"
  225.    #debug concat("       sphere { <0, ",TRUNKLEN,", 0>, ",TRUNKCAPR," }\n")
  226.    #debug        "       #declare NROFSPHERES = NROFSPHERES + 1\n"
  227.    #debug concat("       #ifdef ( MOD_TR )\n")
  228.    #debug        "          // falls definiert, Texture Modifier einfⁿgen\n"
  229.    #debug concat("          texture { MOD_TR }\n")
  230.    #debug        "       #end\n"
  231.    #debug        "   }\n"
  232. #else
  233.    #debug        "   object\n"
  234.    #debug        "   {\n"
  235.    #debug        "      NEWTRUNK\n"
  236.    #debug        "   }\n"
  237. #end
  238.  
  239. // Erzeugung des Include-Files
  240. // Erste Schleifenrunde: ╓ffnen aller Rekursionsstufen
  241.  
  242. #while ( INCDEPTH < DEPTH )
  243.    #debug           "// SchleifenzΣhler auf Anzahl (─ste+Differenz) und in\n"
  244.    #debug           "// AbhΣngigkeit v.d. aktuellen Rekursionsstufe setzen.\n"
  245.    #debug    concat("#declare X = ",str(INCDEPTH,0,0),"\n")
  246.    #debug    concat("#declare DEPTH_",str(INCDEPTH,0,0)," = (",NRBRANCHES,"+(rand(RANDNRBDIFF_",OBJECTNAME,")*",NRBDIFF,"))*pow(",NRBSCALEMUL,",",str(INCDEPTH,0,0),")+(",NRBSCALEADD,"*",str(INCDEPTH,0,0),")\n")
  247.    #debug    concat("#while ( DEPTH_",str(INCDEPTH,0,0)," > 0 )\n")
  248.    #if ( INCDEPTH != DEPTH-1 )
  249.       #debug concat("   // Rekursionsstufe: ",str(INCDEPTH,0,0),"\n")
  250.       #debug        "   union\n"
  251.       #debug        "   {\n"
  252.       #debug        "      // Aktuellen Astradius berechnen\n"
  253.       #debug concat("      #declare ACTRAD = (",RADIUS,"-(rand(RANDRDIFF_",OBJECTNAME,")*",RDIFF,"))*pow(",RADSCALE,",",str(INCDEPTH,0,0),") \n")
  254.       #debug        "      // Aktuelle AstlΣnge berechnen\n"
  255.       #debug concat("      #declare BLEN_",str(INCDEPTH,0,0)," = (",BLEN,"+(rand(RANDLDIFF_",OBJECTNAME,")*",LDIFF,"))*pow(",RECSCALE,",",str(INCDEPTH,0,0),")\n")
  256.       #debug concat("      cone { <0, 0, 0>, ACTRAD, <0, BLEN_",str(INCDEPTH,0,0),", 0>, ACTRAD*(",RADSCALE,") }\n")
  257.       #debug        "      #declare NROFCONES = NROFCONES + 1\n"
  258.       #debug concat("      sphere { <0, BLEN_",str(INCDEPTH,0,0),", 0>, ACTRAD*(",RADSCALE,") }\n")
  259.       #debug        "      #declare NROFSPHERES = NROFSPHERES + 1\n"
  260.  
  261.    #else
  262.       #if ( strcmp(LEAFINC,"YES") = 0 )
  263.          #debug     "   union\n"
  264.       #else
  265.          #debug     "   object\n"
  266.       #end
  267.       #debug        "   {\n"
  268.       #debug        "      // Aktuellen Astradius berechnen\n"
  269.       #debug concat("      #declare ACTRAD = (",RADIUS,"-(rand(RANDRDIFF_",OBJECTNAME,"))*",RDIFF,")*pow(",RADSCALE,",",str(INCDEPTH,0,0),") \n")
  270.       #debug        "      // Unterste Astebene ohne abschlie▀ende Kugel\n"
  271.       #debug concat("      #declare BLEN_",str(INCDEPTH,0,0)," = (",BLEN,"+(rand(RANDLDIFF_",OBJECTNAME,")*",LDIFF,"))*pow(",RECSCALE,",",str(INCDEPTH,0,0),")\n")
  272.       #debug concat("      cone { <0, 0, 0>, ACTRAD, <0, BLEN_",str(INCDEPTH,0,0),", 0>, ACTRAD*",RADSCALE," }\n")
  273.       #debug        "      #declare NROFCONES = NROFCONES + 1\n"
  274.  
  275.       #if ( strcmp(LEAFINC,"YES") = 0 )
  276.          #debug        "      // BlΣtter erzeugen\n"
  277.          #debug        "      // BlattzΣhler\n"
  278.          #debug concat("      #declare LEAFCNT = ",NRLEAFS," + (int(rand(RANDNRLDIFF_",OBJECTNAME,")*",NRLDIFF,"))\n")
  279.          #debug        "      #while ( LEAFCNT > 0 )\n"
  280.          #debug        "         object\n"
  281.          #debug        "         {\n"
  282.          #debug        "            // Blatt auswⁿrfeln\n"
  283.          #debug concat("            #switch( int( rand(RANDLEAFSELECT_",OBJECTNAME,") * (",NRLEAFS,"-1) ) )\n")
  284.  
  285.          #declare LCOUNT = 0
  286.          #while ( LCOUNT < NRLEAFINCS )
  287.             #debug concat("               #case ( ",str(LCOUNT,0,0)," )\n")
  288.             #debug concat("                  LEAFINC_",str(LCOUNT,0,0),"\n")
  289.             #debug        "               #break\n"
  290.             #declare LCOUNT = LCOUNT + 1
  291.          #end
  292.          #debug        "               #else\n"
  293.          #debug        "                  LEAFINC_0\n"
  294.          #debug        "            #end\n"
  295.          #debug        "            #declare NROFLEAFS = NROFLEAFS + 1\n"
  296.          #debug        "            rotate <90, 0, 0>\n"
  297.          #debug concat("            #declare randy = 360*rand(RANDLEAFROT_",OBJECTNAME,")\n")
  298.          #debug concat("            rotate <0, randy, 0>\n")
  299.          #debug concat("            translate <0, rand(RANDLEAFTRANS_",OBJECTNAME,")*BLEN_",str(INCDEPTH,0,0),", 0>\n")
  300.          #debug        "         }\n"
  301.          #debug        "         #declare LEAFCNT = LEAFCNT - 1\n"
  302.          #debug        "      #end\n"
  303.       #end
  304.  
  305.    #end
  306.    #debug "\n"
  307.    #declare INCDEPTH = INCDEPTH+1
  308. #end
  309.  
  310.  
  311. // Zweite Schleifenrunde, Texture-Modifier, transformationen, Schliessen der Rekursionsstufen
  312.  
  313. #declare INCDEPTH = DEPTH-1
  314. #while ( INCDEPTH != -1 )
  315.    #debug    concat("      #ifdef ( MOD_",str(INCDEPTH,0,0)," )\n")
  316.    #debug           "         // falls definiert, Texture Modifier einfⁿgen\n"
  317.    #debug    concat("         texture { MOD_",str(INCDEPTH,0,0)," }\n")
  318.    #debug           "      #end\n"
  319.    #debug           "      // Astneigung\n"
  320.    #debug    concat("      #declare randx = (",SLOPEANGLE,"+(rand(RANDSDIFF_",OBJECTNAME,")*",SANGLEDIFF,"))*pow(",ANGLESCALE,",",str(INCDEPTH-1,0,0),")\n")
  321.    #debug    concat("      rotate <randx, 0, 0>\n")
  322.    #debug           "      // Innerhalb des Rotationsbereiches drehen\n"
  323.    #debug    concat("      #declare randy = ",ROTRANGE,"*rand(RANDROT_",OBJECTNAME,")\n")
  324.    #debug    concat("      rotate <0, randy, 0>\n")
  325.    #if ( INCDEPTH > 0 )
  326.       #debug        "      // am Ansatzast verschieben\n"
  327.       #debug concat("      #if ( rand(RANDBT_",OBJECTNAME,") < ",BRANCHTOP," )\n")
  328.       #debug        "         // an Astspitze verschieben\n"
  329.       #debug concat("         translate <0, BLEN_",str(INCDEPTH-1,0,0),", 0>\n")
  330.       #debug        "      #else\n"
  331.       #debug        "         // an beliebigen Punkt verschieben\n"
  332.       #debug concat("         translate <0, (BLEN_",str(INCDEPTH-1,0,0),")*rand(RANDBT_",OBJECTNAME,"), 0>\n")
  333.       #debug        "      #end\n"
  334.    #else
  335.       #debug        "      // Ans Stammende des Baumes verschieben\n"
  336.       #debug concat("      translate <0, ",TRUNKLEN,", 0>\n")
  337.    #end
  338.    #debug           "   }\n"
  339.    #debug    concat("   #declare DEPTH_",str(INCDEPTH,0,0)," = DEPTH_",str(INCDEPTH,0,0)," - 1\n")
  340.    #debug           "#end\n"
  341.    #declare INCDEPTH = INCDEPTH-1
  342. #end
  343.  
  344. // Schliessen der Union Tree
  345. #debug "}\n\n"
  346.  
  347.  
  348. // Ausgabe der Statistiken
  349. #debug        "#statistics     \"\\n\\n    SELFTREE STATISTICS:\\n\" \n"
  350. #debug        "#statistics         \" --------------------------\\n\" \n"
  351. #debug concat("#statistics  concat(\" Objectname        : ",OBJECTNAME,"\\n\") \n")
  352. #debug        "#statistics         \" --------------------------\\n\" \n"
  353. #debug        "#statistics  concat(\" Number of cones   : \",str(NROFCONES, 6, 0),\"\\n\") \n"
  354. #debug        "#statistics  concat(\" Number of spheres : \",str(NROFSPHERES, 6, 0),\"\\n\") \n"
  355. #debug        "#statistics  concat(\" Number of leafs   : \",str(NROFLEAFS, 6, 0),\"\\n\") \n"
  356. #debug        "#statistics         \" --------------------------\\n\" \n"
  357. #debug        "#statistics  concat(\" Total             : \",str(NROFLEAFS+NROFSPHERES+NROFCONES, 6, 0),\"\\n\") \n"
  358.  
  359. #debug "\n\n\n\n\n"
  360.  
  361.  
  362.  
  363.